//
//  BasePresentationController.h
//  wozhua
//
//  Created by 王洋 on 16/3/22.
//  Copyright © 2016年 王洋. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "MZFormSheetPresentationViewController.h"

@interface BasePresentationController : NSObject

@property (nonatomic, readonly, strong, nullable) UIViewController *contentViewController;

/**
 Corner radius of content view
 By default, this is 5.0
 */
@property (nonatomic, assign) CGFloat contentViewCornerRadius;

/**
 The blur radius (in points) used to render the layer’s shadow.
 By default, this is 6.0
 */
@property (nonatomic, assign) CGFloat shadowRadius;

@property (nonatomic, assign) MZFormSheetPresentationTransitionStyle contentViewControllerTransitionStyle;

/**
 *  The preferred size for the container’s content. (required)
 */
@property (nonatomic, assign) CGSize contentViewSize;

/**
 Distance that the presented form sheet view is inset from the status bar in landscape orientation.
 By default, this is 6.0
 */
@property (nonatomic, assign) CGFloat landscapeTopInset;

/**
 Distance that the presented form sheet view is inset from the status bar in portrait orientation.
 By default, this is 66.0
 */
@property (nonatomic, assign) CGFloat portraitTopInset;

/**
 Returns whether the form sheet controller should dismiss after background view tap.
 By default, this is NO
 */
@property (nonatomic, assign) BOOL shouldDismissOnBackgroundViewTap;

/**
 Center form sheet vertically.
 By default, this is NO
 */
@property (nonatomic, assign) BOOL shouldCenterVertically;

/**
 The background color of the background view.
 By default, this is a black at with a 0.5 alpha component
 */
@property (nonatomic, strong, nullable) UIColor *backgroundColor MZ_APPEARANCE_SELECTOR;

/**
 The movement action to use when the keyboard appears.
 By default, this is MZFormSheetActionWhenKeyboardAppears.
 */
@property (nonatomic, assign) MZFormSheetActionWhenKeyboardAppears movementActionWhenKeyboardAppears MZ_APPEARANCE_SELECTOR;

/**
 The handler to call when presented form sheet is before entry transition and its view will show on window.
 */
@property (nonatomic, copy, nullable) MZFormSheetPresentationViewControllerCompletionHandler willPresentContentViewControllerHandler;

/**
 The handler to call when presented form sheet is after entry transition animation.
 */
@property (nonatomic, copy, nullable) MZFormSheetPresentationViewControllerCompletionHandler didPresentContentViewControllerHandler;

/**
 The handler to call when presented form sheet will be dismiss, this is called before out transition animation.
 */
@property (nonatomic, copy, nullable) MZFormSheetPresentationViewControllerCompletionHandler willDismissContentViewControllerHandler;

/**
 The handler to call when presented form sheet is after dismiss.
 */
@property (nonatomic, copy, nullable) MZFormSheetPresentationViewControllerCompletionHandler didDismissContentViewControllerHandler;

/**
 The handler to call when user tap on background view.
 */
@property (nonatomic, copy, nullable) MZFormSheetPresentationControllerTapHandler didTapOnBackgroundViewCompletionHandler;

/**
 *  Notifies the presentation controller that the presentation animations are about to start.
 */
@property (nonatomic, copy, nullable) MZFormSheetPresentationControllerTransitionBeginCompletionHandler presentationTransitionWillBeginCompletionHandler;

/**
 *  Notifies the presentation controller that the presentation animations finished.
 */
@property (nonatomic, copy, nullable) MZFormSheetPresentationControllerTransitionEndCompletionHandler presentationTransitionDidEndCompletionHandler;

/**
 *  Notifies the presentation controller that the dismissal animations are about to start.
 */
@property (nonatomic, copy, nullable) MZFormSheetPresentationControllerTransitionBeginCompletionHandler dismissalTransitionWillBeginCompletionHandler;

/**
 *  Notifies the presentation controller that the dismissal animations finished.
 */
@property (nonatomic, copy, nullable) MZFormSheetPresentationControllerTransitionEndCompletionHandler dismissalTransitionDidEndCompletionHandler;

/**
 *  This completion handler allow you to change frame during rotation and animations
 *  for presentedView
 */
@property (nonatomic, copy, nullable) MZFormSheetPresentationFrameConfigurationHandler frameConfigurationHandler;

@property (nonatomic, readonly, strong, nullable) UIView *dimmingView;

+ (NSArray * __nonnull)presentationControllersStack;
+ (BOOL)isAnimating;

- (nonnull instancetype)initWithContentViewController:(UIViewController * __nonnull)viewController;

- (void)presentFromViewController:(UIViewController * __nonnull )presentingViewController animated: (BOOL)flag completion:(void (^ __nullable)(void))completion;

- (void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^ __nullable)(void))completion;

@end

@interface UIViewController (BasePresentationController)

@property (nonatomic, readonly, nullable) BasePresentationController *basePresentationController;

//是否弹出了BasePresentationController
@property (nonatomic, assign) BOOL hasBasePresentedController;

- (void)dismissPresentationControllerAnimated:(BOOL)flag completion:(void (^ __nullable)(void))completion;

@end
